
//
//  HistoryView.m
//  GoldOperationClient
//
//  Created by yaxue wang on 16/8/16.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "HistoryView.h"
#import "HistoryTableCell.h"
#import "historyModel.h"
@implementation HistoryView
-(instancetype)initWithFrame:(CGRect)frame withWarningUuid:(NSString *)machineUuid
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setShowNoDataNotice:@"暂无维护记录"];
        self.backgroundColor =[UIColor clearColor];
        self.separatorStyle=UITableViewCellSeparatorStyleNone;
        self.showsVerticalScrollIndicator =NO;
        [self registerCell:[HistoryTableCell class] withModel:[historyModel class]];
        //死的
        [self setDataWithUrl:@"warninglist_machineRepairList" andParam:@{@"machineUuid":machineUuid}];
        [self setTableActionType:CTableActionType_Both];
        [self loadData];
        
    }
    
    return self;
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.mainData.count;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    HistoryTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        cell = [[HistoryTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    historyModel *model = [self.mainData objectAtIndex:indexPath.row];
    [cell setModel:model];
    return cell;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    historyModel *model = [self.mainData objectAtIndex:indexPath.row];
    
    CGSize labelsize = CGSizeZero;
    NSString *context =[NSString stringWithFormat:@"【%@】%@",model.HH_type_name,model.HH_content];
   
    if ([context isEqualToString:@""]) {
//        return 45;
    }else
    {
        
        labelsize = [context sizeWithFont:F(12) constrainedToSize:CGSizeMake(WindowWidth-120-20, 900)];
//          return labelsize.height;
    }
    return MAX(labelsize.height + 20, 65);
}



@end
